home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-03 | 45.4 KB | 1,376 lines |
- C.S.M.P. Digest Sat, 02 May 92 Volume 1 : Issue 68
-
- Today's Topics:
-
- ANSI I/O with Mac user interface in Think C ?
- Floppy Disk Dialog Override?!
- Counting files in a folder?
- How to make program shutdown aware
- Dynamic loading on the Mac?
- DragWindow without SelectWindow?
- Mac development environment questions...
- Video page flipping?
- Shareware C and C++ compilors for the Mac
- scrollbar thumb question
- Summary: Color drawing question
- Strange undocumented think Pascal error message
-
-
- The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
-
- These digests are available (by using FTP, account anonymous, your email
- address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
- edu. This is also the home of the comp.sys.mac.programmer Frequently Asked
- Questions list. The last several issues of the digest are available from
- sumex-aim.stanford.edu as well.
-
- These digests are also available via email. Just send a note saying that you
- want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
- automatically receive each new digest as it is created.
-
- The articles in these digests are taken directly from comp.sys.mac.programmer.
- They are not edited; all articles included in this digest are in their original
- posted form. The only articles that are -not- included in these digests are
- those which didn't receive any replies (except those that give information
- rather than ask a question). All replies to each article are concatenated
- onto the original article in the order in which they were received. Article
- threads are not added to the digests until the last article added to the
- thread is at least one month old (this is to ensure that the thread is dead
- before adding it to the digests).
-
- Send administrative mail to mkelly@cs.uoregon.edu.
-
- -------------------------------------------------------
-
- From: ay@duke.cs.duke.edu (Akitoshi Yoshida)
- Subject: ANSI I/O with Mac user interface in Think C ?
- Date: 24 Mar 92 19:09:35 GMT
- Organization: Duke University Computer Science Dept.; Durham, N.C.
-
- I would like to use ANSI standard formatted I/O functions such as
- fprintf() and fscanf(). At the same time, I would like to use the Mac
- interface provided by SFGetFile(). Could someone tell me what is the
- standard way to do this? Right now I am using my own version of
- fscanf() based on FSRead(), but I hope there is a simpler way.
-
- I thought about getting a patial path name to the file somehow and
- then using fopen() with it. But SFGetFile() only gives vRefNum and
- fileName, etc, so I don't know how to do this. Another possibility is
- to set the working directory to the one where the file is placed, and
- then to call fopen() with fileName.
-
- Thank you for your help.
- ay@cs.duke.edu
-
-
-
-
- - --
- - ---
- Akitoshi Yoshida $B5HED L@=S(B
- Department of Computer Science, Duke University, Durham, NC 27706
- INTERNET: ay@cs.duke.edu TEL : (919)-660-6561
-
- +++++++++++++++++++++++++++
-
- From: e-sink@uiuc.edu (Eric W. Sink)
- Date: 24 Mar 92 22:06:43 GMT
- Organization: University of Illinois at Urbana-Champaign
-
- In <701464173@aphid.cs.duke.edu> ay@duke.cs.duke.edu (Akitoshi Yoshida) writes:
-
- >I would like to use ANSI standard formatted I/O functions such as
- >fprintf() and fscanf(). At the same time, I would like to use the Mac
- >interface provided by SFGetFile(). Could someone tell me what is the
- >standard way to do this? Right now I am using my own version of
- >fscanf() based on FSRead(), but I hope there is a simpler way.
-
- >I thought about getting a patial path name to the file somehow and
- >then using fopen() with it. But SFGetFile() only gives vRefNum and
- >fileName, etc, so I don't know how to do this. Another possibility is
- >to set the working directory to the one where the file is placed, and
- >then to call fopen() with fileName.
-
- A little blurry, because it's off the top of my head:
-
- Using ftp to ftp.apple.com, snarf the Sample Code which deals with
- StandardGetFile. That code contains a function which converts a
- vrefnum/dirID to a full path specification.
-
- Modify this function a little bit to accept a file name too, returning
- a full path to the file. Basically, the function concats each directory
- name one at a time. You just concat the file name at the very end.
- Call this function :
-
- void FilePath(char *name, short vRefNum, long dirID, char *pathBuf);
-
- Now write a function called fopenMAC (or whatever you want to call it),
- like this :
-
- FILE *fopenMAC(char *name, short vRefNum, long dirID, char *perms)
- {
- char path[512];
- FilePath(name,vRefNum,dirID,path);
- return fopen(path,perms);
- }
-
- I use this all the time, except the code is on my Mac. Email me if this
- is all a bit too blurry.
-
- - --
- Eric W. Sink, Spatial Analysis and Systems Team
- USACERL, P.O. Box 9005, Champaign, IL 61826-9005
- 1-800-USA-CERL x449, e-sink@uiuc.edu
-
- +++++++++++++++++++++++++++
-
- From: ross@bnr.ca (Ross Brown)
- Date: 25 Mar 92 14:56:15 GMT
- Organization: Bell-Northern Research
-
- In article <1992Mar24.220643.24600@sunb10.cs.uiuc.edu> e-sink@uiuc.edu (Eric W.
- Sink) writes:
- >In <701464173@aphid.cs.duke.edu> ay@duke.cs.duke.edu (Akitoshi Yoshida)
- writes:
- >
- >>I would like to use ANSI standard formatted I/O functions such as
- >>fprintf() and fscanf(). At the same time, I would like to use the Mac
- >>interface provided by SFGetFile().
- >>[stuff deleted]
- >
- >Using ftp to ftp.apple.com, snarf the Sample Code which deals with
- >StandardGetFile. That code contains a function which converts a
- >vrefnum/dirID to a full path specification.
- >[more stuff deleted]
-
- This is a common requirement, so as a public service, I present an excerpt from
- Jon Pugh's FinderEvents stack source (Copyright 1991, Apple Computer) which
- does just what you want. I'm sure Jon doesn't mind. Use FSMakeFSSpec to get
- from {name,vRefNum,dirID} to FSSpec.
-
- FUNCTION PathName (theFSS : FSSpec) : Str255;
- VAR
- Block : CInfoPBRec;
- directoryName, FullPathName : Str255;
- err : OSErr;
- BEGIN
- FullPathName := '';
- WITH block DO
- BEGIN
- ioNamePtr := @directoryName;
- ioDrParID := theFSS.parID;
- END;
- REPEAT
- WITH block DO
- BEGIN
- ioVRefNum := theFSS.vRefNum;
- ioFDirIndex := -1;
- ioDrDirID := block.ioDrParID;
- END;
- err := PBGetCatInfo(@Block, FALSE);
- directoryName := concat(directoryName,':');
- fullPathName := concat(directoryName, fullPathName);
- UNTIL (block.ioDrDirID = 2);
- PathName := Concat(fullPathName, theFSS.name);
- END; { Pathname }
-
- Ross Brown
- Bell-Northern Research Ltd.
- Ottawa, Ontario, Canada
- ross@bnr.ca
- Opinions expressed do not necessarily represent those of BNR.
-
- +++++++++++++++++++++++++++
-
- From: nurse@vax.oxford.ac.uk
- Date: 31 Mar 92 10:50:43 GMT
- Organization: Oxford University VAXcluster
-
- In article <1992Mar25.145615.3257@bmers95.bnr.ca>, ross@bnr.ca (Ross Brown) writes:
- > In article <1992Mar24.220643.24600@sunb10.cs.uiuc.edu> e-sink@uiuc.edu (Eric W.
- > Sink) writes:
- >>In <701464173@aphid.cs.duke.edu> ay@duke.cs.duke.edu (Akitoshi Yoshida)
- > writes:
- >>
- >>>I would like to use ANSI standard formatted I/O functions such as
- >>>fprintf() and fscanf(). At the same time, I would like to use the Mac
- >>>interface provided by SFGetFile().
- >>>[stuff deleted]
- >>
- >>Using ftp to ftp.apple.com, snarf the Sample Code which deals with
- >>StandardGetFile. That code contains a function which converts a
- >>vrefnum/dirID to a full path specification.
- >>[more stuff deleted]
- >
- > This is a common requirement, so as a public service, I present an excerpt from
- > Jon Pugh's FinderEvents stack source (Copyright 1991, Apple Computer) which
- > does just what you want. I'm sure Jon doesn't mind. Use FSMakeFSSpec to get
- > from {name,vRefNum,dirID} to FSSpec.
- >
- > FUNCTION PathName (theFSS : FSSpec) : Str255;
- > VAR
-
- You can avoid a lot of heartache and hair if you avoid using pathnames and
- follow the advice given in Technical Note #246: Mixing HFS and C File I/O
- There's some sample code in there that I have used for Think C I/O and it
- works a treat! It's also very simple!!!
-
- Kevin Crawford
- ICRF Cell Cycle Group k_crawford@uk.ac.ox.icrf
- Dept of Biochemistry kevin@uk.ac.ox.bioch
- Oxford University nurse@uk.ac.ox.vax
- UK
-
- ---------------------------
-
- From: swb1_ltd@uhura.cc.rochester.edu (Steve Berkley)
- Subject: Floppy Disk Dialog Override?!
- Date: 27 Mar 92 06:15:26 GMT
- Organization: University of Rochester - Rochester, New York
-
- I am writing a program that will read in disks from a different
- machine (a keyboard sampler, actually), and store them as mac
- "image" files, so that disks may be traded between users...
-
- Programs like Norton Utilities will allow you to insert a
- foreign disk (foreign or unformatted) and *keep* it in the
- drive for reading or whatever. This is what I'd like to do-
- how can I do that? Any actual code or pseudo-code would be
- vastly appreciated!
-
- - -SB
-
- +++++++++++++++++++++++++++
-
- From: Keith_Rollin@taligent.com (Keith Rollin)
- Date: 28 Mar 92 03:23:41 GMT
- Organization: Taligent
-
- In article <1992Mar27.061526.5827@galileo.cc.rochester.edu>, swb1_ltd@uhura.cc.rochester.edu (Steve Berkley) writes:
- >
- > I am writing a program that will read in disks from a different
- > machine (a keyboard sampler, actually), and store them as mac
- > "image" files, so that disks may be traded between users...
- >
- > Programs like Norton Utilities will allow you to insert a
- > foreign disk (foreign or unformatted) and *keep* it in the
- > drive for reading or whatever. This is what I'd like to do-
- > how can I do that? Any actual code or pseudo-code would be
- > vastly appreciated!
-
- When a disk is inserted into the system, the frontmost application gets
- a Disk Inserted event. The upper word of the event.message field will
- hold the result of the MountVolume routine. Normally, this word is
- zero, indicating that the disk was successfully mounted. If the word
- is not zero, then there was a problem, and you should normally call
- DIBadMount. I imagine that you could opt to do something else, like
- try reading the disk directly (the drive number is in the low word
- of the event.message field).
-
- - --
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-
- +++++++++++++++++++++++++++
-
- From: Keith_Rollin@taligent.com (Keith Rollin)
- Date: 28 Mar 92 03:23:41 GMT
- Organization: Taligent
-
- In article <1992Mar27.061526.5827@galileo.cc.rochester.edu>, swb1_ltd@uhura.cc.rochester.edu (Steve Berkley) writes:
- >
- > I am writing a program that will read in disks from a different
- > machine (a keyboard sampler, actually), and store them as mac
- > "image" files, so that disks may be traded between users...
- >
- > Programs like Norton Utilities will allow you to insert a
- > foreign disk (foreign or unformatted) and *keep* it in the
- > drive for reading or whatever. This is what I'd like to do-
- > how can I do that? Any actual code or pseudo-code would be
- > vastly appreciated!
-
- When a disk is inserted into the system, the frontmost application gets
- a Disk Inserted event. The upper word of the event.message field will
- hold the result of the MountVolume routine. Normally, this word is
- zero, indicating that the disk was successfully mounted. If the word
- is not zero, then there was a problem, and you should normally call
- DIBadMount. I imagine that you could opt to do something else, like
- try reading the disk directly (the drive number is in the low word
- of the event.message field).
-
- - --
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-
- +++++++++++++++++++++++++++
-
- From: russotto@eng.umd.edu (Matthew T. Russotto)
- Date: Mon, 30 Mar 92 15:44:57 GMT
- Organization: College of Engineering, University of Maryland, College Park
-
- In article <1992Mar27.061526.5827@galileo.cc.rochester.edu> swb1_ltd@uhura.cc.rochester.edu (Steve Berkley) writes:
- >I am writing a program that will read in disks from a different
- >machine (a keyboard sampler, actually), and store them as mac
- >"image" files, so that disks may be traded between users...
- >
- >Programs like Norton Utilities will allow you to insert a
- >foreign disk (foreign or unformatted) and *keep* it in the
- >drive for reading or whatever. This is what I'd like to do-
- >how can I do that? Any actual code or pseudo-code would be
- >vastly appreciated!
-
- Before system 7, the answer was to handle the disk-inserted event
- yourself-- i.e. DON'T call DIBadMount. I seem to recall having
- problems with this under system 7 (the Finder would get the
- disk-inserted event). But I could be mistaken.
-
- All you do to read it is use the .Sony driver.
- - --
- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu
- Some news readers expect "Disclaimer:" here.
- Just say NO to police searches and seizures. Make them use force.
- (not responsible for bodily harm resulting from following above advice)
-
- ---------------------------
-
- From: PS9ZRHMC@MIAMIU.BITNET (Peter Sweeney)
- Subject: Counting files in a folder?
- Date: 27 Mar 92 17:14:08 GMT
- Organization: Miami University - Academic Computer Service
-
- I'd like to obtain a count of the number of files in a particular
- folder. I'd like to then be able to either quit the
- application if the number is too large, or launch another
- application if the number is okay.
-
- Can I do this (easily) with THINK C? Or is HyperCard a better
- way to achieve this goal? Is there an XCMD that will do this?
- The Rinaldi External collection, maybe?
-
- Any response is welcome.
-
- Peter Sweeney
- ps9zrhmc@miamiu.acs.muohio.edu
-
- +++++++++++++++++++++++++++
-
- From: buckeye@spf.trw.com (John Wallace)
- Organization: TRW Data Systems Center, Redondo Beach, CA
- Date: Fri, 27 Mar 92 20:55:54 GMT
-
- In article <92087.121409PS9ZRHMC@MIAMIU.BITNET> PS9ZRHMC@MIAMIU.BITNET (Peter Sweeney) writes:
- >I'd like to obtain a count of the number of files in a particular
- >folder. I'd like to then be able to either quit the
- >application if the number is too large, or launch another
- >application if the number is okay.
- >
- >Can I do this (easily) with THINK C? Or is HyperCard a better
- >way to achieve this goal? Is there an XCMD that will do this?
- >The Rinaldi External collection, maybe?
- >
- >Any response is welcome.
- >
- >Peter Sweeney
- >ps9zrhmc@miamiu.acs.muohio.edu
-
-
- In Pascal you could do something like:
-
-
- (* CountNumFiles
- * Counts the number of files in a directory and all of its
- * sub-directories. Files can be indicated by name (in which
- * case index should be passed in as 0) or by an index >= 1
- * (in which case fileName is ignored).
- *)
- function CountNumFiles( vRefNum:Integer;
- parId:LongInt;
- fileName:Str255;
- index:Integer;
- countDirsToo:Boolean) : LongInt;
- var
- pb : CInfoPBRec;
- count : LongInt;
- begin
- pb.ioVRefNum := vRefNum;
- pb.ioDirId := parId;
- pb.ioNamePtr := @dirName;
- pb.ioFDirIndex := index;
- if PBGetCatInfo(@pb, false) = noErr then
- begin
- (* If it's a file then just return one *)
- if pb.ioFlAttrib = 0 then
- CountNumFiles := 1
-
- (* If it's a directory, then count all of its children *)
- else
- begin
- if countDirsToo then
- count := 1
- else
- count := 0;
-
- (* Recursively count all of the sub-files *)
- for i := 1 to pb.ioDrNmFls do
- count := count + CountNumFiles(vRefNum,
- pb.ioDrDirId, '', i, countDirsToo);
-
- CountNumFiles := count;
- end;
- end;
- end;
-
-
- procedure SomeProcThatNeedsToCountFiles;
- var
- count : LongInt;
- begin
- (* ... Find the vRefNum, dirId, and name of the directory ... *)
-
- count := CountNumFiles(vRefNum, parId, dirName, 0, false);
- WriteLn(dirName, ' countains ', count:1, ' files.');
-
- (* ... Whatever else you do ... *)
- end;
-
-
- (NOTE: This was off the top of my head, so there may be typos.
- However, I use a routine like this to walk through the directory
- tree in some of my code, so it should work otherwise.)
-
-
- Cheers!
- John
-
- - -----
- John Wallace buckeye@spf.trw.com
-
- Unix C programmer by day, Mac Pascal programmer by night!
- (Ahhh, I live for the night!!)
-
- +++++++++++++++++++++++++++
-
- From: d88-jwa@alv.nada.kth.se (Jon W{tte)
- Date: 28 Mar 92 22:49:42 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- > PS9ZRHMC@MIAMIU.BITNET (Peter Sweeney) writes:
-
- I'd like to obtain a count of the number of files in a particular
- folder. I'd like to then be able to either quit the
- application if the number is too large, or launch another
- application if the number is okay.
-
- You can get the valence of a folder by using PBGetCatInfo on it
- once. However, valence == files + folders in the folder, so if you
- need to know the number of files (perhaps even of a specific type)
- you will have to iterate over the folder using indexed PBGetCatInfo
- to check which files are OK.
-
- - --
- h+@nada.kth.se; Jon W{tte, the Diplomat - NOT!
-
- +++++++++++++++++++++++++++
-
- From: geo@syd.dit.csiro.au (George Bray)
- Organization: Sand Consulting, Guest of CSIRO Australia
- Date: Wed, 1 Apr 92 08:29:04 GMT
-
-
-
- Not sure if this is in the archives. - geo
-
-
- GetDir 2.2
-
- ---------------------------
-
- From: Hyperion@Altyr4.dnet.nasa.gov (Paul D. Haggerty)
- Subject: How to make program shutdown aware
- Date: 27 Mar 92 19:07:21 GMT
- Organization: Science Systems and Applications, Inc.
-
- I've written a short routine which runs continously in the background.
- The problem is that I can no longer shut down the machine. I've
- tried using ShutDwnInstall to put in a routine which calls exittoshell,
- but it doesn't seem to have any affect.
-
- Can anyone tell me how I can get my program to shut itself down in
- the case of RESTART or SHUTDOWN?
-
- Thanks for any help?
-
- Paul D. Haggerty
-
- +++++++++++++++++++++++++++
-
- From: dawg6844@uxa.cso.uiuc.edu (Dan Walkowski)
- Organization: University of Illinois at Urbana
- Date: Fri, 27 Mar 1992 20:33:47 GMT
-
- Hyperion@Altyr4.dnet.nasa.gov (Paul D. Haggerty) writes:
-
- >I've written a short routine which runs continously in the background.
- >The problem is that I can no longer shut down the machine. I've
- >tried using ShutDwnInstall to put in a routine which calls exittoshell,
- >but it doesn't seem to have any affect.
-
- >Can anyone tell me how I can get my program to shut itself down in
- >the case of RESTART or SHUTDOWN?
-
- >Thanks for any help?
-
- >Paul D. Haggerty
-
- It must either:
-
- 1) have a menu named 'File', and in that menu have an item named 'Quit'.
- _or_
- 2) understand and respond to a quit appleevent
-
- Dan
-
- - --
- Dan Walkowski
- Univ. of Illinois
- walkowsk@cs.uiuc.edu
- - ---------------------------------------------------------------------------
-
- +++++++++++++++++++++++++++
-
- From: mauser@intercon.com (Richard Chandler)
- Date: 31 Mar 92 18:20:03 GMT
- Organization: InterCon Systems Corporation
-
- In article <1992Mar27.203347.19060@ux1.cso.uiuc.edu>,
- dawg6844@uxa.cso.uiuc.edu (Dan Walkowski) writes:
- > Hyperion@Altyr4.dnet.nasa.gov (Paul D. Haggerty) writes:
- >
- > >I've written a short routine which runs continously in the background.
- > >The problem is that I can no longer shut down the machine. I've
- > >tried using ShutDwnInstall to put in a routine which calls exittoshell,
- > >but it doesn't seem to have any affect.
- >
- > >Can anyone tell me how I can get my program to shut itself down in
- > >the case of RESTART or SHUTDOWN?
- >
- > >Thanks for any help?
- >
- > >Paul D. Haggerty
- >
- > It must either:
- >
- > 1) have a menu named 'File', and in that menu have an item named 'Quit'.
-
- It can deviate from this if it has the right 'mstr' or 'mst#' resources.
- 100 for the menu, and 101 for the menu item.
-
- > _or_
- > 2) understand and respond to a quit appleevent
-
- - --
- People are more violently opposed to fur than leather, because it's safer to
- harass rich women than biker gangs.
- "Ride a motorcycle. Save Gas, Oil, Rubber, Steel, Aluminum, Parking Spaces,
- The Environment, and Money. Plus, you get to wear all the leather you want!"
- Rich Chandler, DoD #296
-
- +++++++++++++++++++++++++++
-
- From: lsr@taligent.com (Larry Rosenstein)
- Date: 31 Mar 92 22:42:38 GMT
- Organization: Taligent, Inc.
-
- In article <1992Mar27.203347.19060@ux1.cso.uiuc.edu>, dawg6844@uxa.cso.uiuc.edu
- (Dan Walkowski) writes:
- >
- > Hyperion@Altyr4.dnet.nasa.gov (Paul D. Haggerty) writes:
- >
- > >I've written a short routine which runs continously in the background.
- > >The problem is that I can no longer shut down the machine. I've
-
- > It must either:
- >
- > 1) have a menu named 'File', and in that menu have an item named 'Quit'.
- > _or
- > _2) understand and respond to a quit appleevent
-
- or
-
- 3) Have an appropriate mstr or mst# resource(s) to define the name of the menu
- and item that contain the program's quit command. I think ID 100 is the menu
- name and 101 is the item name. An mstr resource is exactly the same as a
- STR<space> resource.
- - --
- Larry Rosenstein
- Taligent, Inc.
- lsr@taligent.com
-
- ---------------------------
-
- From: turpin@cs.utexas.edu (Russell Turpin)
- Subject: Dynamic loading on the Mac?
- Date: 28 Mar 1992 11:00:12 -0600
- Organization: CS Dept, University of Texas at Austin
-
- - -*----
- On most Unix boxes, there are standard library calls to
- dynamically load procedures. The calling program passes
- the name of an object file (or source file to be compiled),
- the name of a procedure in the object file, and the system
- loads the procedure into memory and returns a pointer to
- it. The procedure can then be invoked through the pointer.
- (If the procedure contains unresolved references, an
- error results.)
-
- Is there any comparable facility in the Mac environment?
-
- Russell
-
-
- +++++++++++++++++++++++++++
-
- From: jv0l+@andrew.cmu.edu (Justin Chris Vallon)
- Date: 28 Mar 92 21:02:37 GMT
- Organization: Junior, Electrical and Computer Engineering, Carnegie Mellon, Pittsburgh, PA
-
- Excerpts from netnews.comp.sys.mac.programmer: 28-Mar-92 Dynamic loading
- on the Mac? Russell Turpin@cs.utexas (493)
-
- > -*----
- > On most Unix boxes, there are standard library calls to
- > dynamically load procedures. The calling program passes
- > the name of an object file (or source file to be compiled),
- > the name of a procedure in the object file, and the system
- > loads the procedure into memory and returns a pointer to
- > it. The procedure can then be invoked through the pointer.
- > (If the procedure contains unresolved references, an
- > error results.)
-
- > Is there any comparable facility in the Mac environment?
-
- > Russell
-
- The Macintosh stores the executable code in resources. A resource file
- on the Mac may be defined as:
-
- typedef long ResourceType; /* ResourceType is typically a string of
- four characters: 'CODE', 'MENU', 'DLOG', but may be a long. */
- typedef char Resource[32768];
- typedef int ResourceID;
- typedef Resource ResourceFile[ResourceID][ResourceType];
-
- Of course, the resources are not stored in an array. A code resource is
- a resource that typically starts at offset 0. Most development
- environments allow the generation of code resources. Most of the
- specifics of the creation of a code resource is dependent upon the
- compiler. However, the overall structure is usually the same. A single
- procedure or function is created, main, whose offset is 0.
-
- Conflicts arise when the code resource attempts to access "global"
- variables, since the global scope of the code resource is not the global
- scope of the application. The code resource will usually store the
- variables statically in the code resource, or in a stack frame. The
- compiler will usually generate code that initializes A4 to point to a
- space that the resource may use for global storage. The space will
- usually be lost when the resource is purged.
-
- Multiple entry points to an object file is usually accomplished through
- a dispatch mechanism. The main procedure is takes an additional
- parameter that determines which of the n routines should be called.
-
- Runtime compilation is a complex problem.
-
- - -Justin
- jv0l+@andrew.cmu.edu
-
- +++++++++++++++++++++++++++
-
- From: bpb9204@tamsun.tamu.edu (Brent)
- Date: 28 Mar 92 23:04:32 GMT
- Organization: Texas A&M Univ., Inc.
-
- turpin@cs.utexas.edu (Russell Turpin) writes:
- |-*----
- |On most Unix boxes, there are standard library calls to
- | [...]
- |Is there any comparable facility in the Mac environment?
-
-
- Russell,
- yes there is and it's relatively simple. For the external code modules
- you would create a stand-alone code resource (of whatever res type you
- want that won't cause a conflict elsewhere). In your calling program
- you would load the resource in (getting it is up to you/your program)
- and then effective call it (jsr to it). The following pseudocode may help:
-
- typedef void (**fcn_hdl)(void);
-
- void run_code_module( ResType type, int id)
- {
- fcn_hdl fp = GetResource( type, id);
-
- if (fp == NULL) { error(); return; }
- HLock(fp);
- (**fp)(); /* call it */
- Hunlock(fp);
- /* dispose of it here */
- ReleaseResource(fp); /* or whatever */
- }
-
- You would then pull this off by calling it thusly:
- run_code_module( (ResType)'JUNK', 999);
-
- The following code would then be compiled into resource type JUNK with
- ID 999:
-
- void main(void)
- {
- SysBeep(1);
- }
-
- Notice that the definition of main() is the same as what fcn_hdl would
- point to. Once the resource (code) is loaded, you call it just like
- any other procedure (except for the double indirection) and the parameters
- must match.
-
- Hope this helps.
-
- - -Brent
- - --
- - ------------------------------------------------------------------------------
- Brent P. Burton, N5VMG Computer Sci/Physics
- bpb9204@tamsun.tamu.edu Texas A&M University
- - ------------------------------------------------------------------------------
-
- +++++++++++++++++++++++++++
-
- From: peirce@outpost.SF-Bay.org (Michael Peirce)
- Date: 29 Mar 92 06:10:51 GMT
- Organization: Peirce Software
-
- Beside the use of CODE type resource which others have mentioned,
- there is a new thing called DINKER. This is a dynamic linker that
- will bind code to an app at a much higher level than the code resource
- approach.
-
- DINKER isn't production quality yet, but it does some really fine
- things like binding in classes (Object Pascal or C++) at run time.
- This will allow a MacApp program to call new subclasses at run time.
-
- It's on the latest ETO disk from Apple. Check it out!
-
- - -- Michael Peirce -- peirce@outpost.SF-Bay.org
- - -- Peirce Software -- Suite 301, 719 Hibiscus Place
- - -- Macintosh Programming -- San Jose, California USA 95117
- - -- & Consulting -- voice: (408) 244-6554 fax: (408) 244-6882
- - -- -- AppleLink: peirce & America Online: AFC Peirce
-
- +++++++++++++++++++++++++++
-
- From: turpin@cs.utexas.edu (Russell Turpin)
- Date: 29 Mar 1992 18:53:02 -0600
- Organization: U Texas Dept of Computer Sciences, Austin TX
-
- - -*----
- Justin Vallon gives a strong answer to the dynamic loading question,
- but then he notes (article <8dpBvh_00VpK4Gl0o7@andrew.cmu.edu>):
-
- > Runtime compilation is a complex problem.
-
- Unfortunately, this is the reason I was asking about dynamic loading.
- On Unix boxes, runtime compilation is dirt simple, because of Unix's
- clean process control. (Yes, folks, it helps to run on a real OS.)
-
- Are there C compilers that can be linked into into and invoked from
- an application? Why is this a "complex problem"?
-
- Russell
-
- +++++++++++++++++++++++++++
-
- From: d88-jwa@hemul.nada.kth.se (Jon W{tte)
- Date: 30 Mar 92 20:32:00 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- > turpin@cs.utexas.edu (Russell Turpin) writes:
-
- Are there C compilers that can be linked into into and invoked from
- an application? Why is this a "complex problem"?
-
- Yes.
-
- MPW has a ToolServer that accepts AppleEvents to, among other things,
- compile C code, and make a code resource or dynamically loadable
- object. Then use GetResource, or the new dynamic linker stuff, and
- off you go !
-
- - --
- h+@nada.kth.se; Jon W{tte, the Diplomat - NOT!
-
- +++++++++++++++++++++++++++
-
- From: jv0l+@andrew.cmu.edu (Justin Chris Vallon)
- Date: 30 Mar 92 21:40:49 GMT
- Organization: Junior, Electrical and Computer Engineering, Carnegie Mellon, Pittsburgh, PA
-
- Excerpts from netnews.comp.sys.mac.programmer: 30-Mar-92 Re: Dynamic
- loading on the .. Russell Turpin@cs.utexas (522)
-
- > -*----
- > Justin Vallon gives a strong answer to the dynamic loading question,
- > but then he notes (article <8dpBvh_00VpK4Gl0o7@andrew.cmu.edu>):
-
- > > Runtime compilation is a complex problem.
-
- > Unfortunately, this is the reason I was asking about dynamic loading.
- > On Unix boxes, runtime compilation is dirt simple, because of Unix's
- > clean process control. (Yes, folks, it helps to run on a real OS.)
-
- > Are there C compilers that can be linked into into and invoked from
- > an application? Why is this a "complex problem"?
-
- Unlike the Unix environment, the notion of a process on a Macintosh is
- an application. Almost all of the development environments are not
- merely applications that compile a source file into an object file, but
- will have editors and front-ends to the compiler.
-
- The MPW environment is a command-line based environment, but there is no
- built-in support for process control. An MPW tool could be written to
- compile a file, but the implementation would be difficult.
-
- > Russell
-
- - -Justin
- jv0l+@andrew.cmu.edu
-
- ---------------------------
-
- From: ollef@sics.se (Olle Furberg)
- Subject: DragWindow without SelectWindow?
- Date: 29 Mar 92 17:44:35 GMT
- Organization: Satellite Image in Kiruna Corporation
-
-
- I'm trying to implement movable modal dialog box.
-
- How could I move an inactive window without getting it activated through
- SelectWindow?
-
-
- /Olle
-
-
- - ------------------------------------------------------------
- Olle Furberg Internet: ollef@sics.se
- Satellitbild in Kiruna Phone: +46 980 121 40
- Swedish Space Corporation Fax: +46 980 160 44
- Home: +46 980 801 95
-
- +++++++++++++++++++++++++++
-
- From: haynes@mace.cc.purdue.edu (Carl W. Haynes III)
- Date: 29 Mar 92 22:33:47 GMT
- Organization: Purdue University Computing Center
-
- In article <1992Mar29.174435.17655@sics.se> ollef@sics.se (Olle Furberg) writes:
- >
- >I'm trying to implement movable modal dialog box.
- >
- >How could I move an inactive window without getting it activated through
- >SelectWindow?
- >
-
- You need to write your own DragWindow routine. Here's what I use:
- I'm sure I stole this from somewhere, but don't remember where off hand.
- As always, add error checking where needed.
-
-
- void DragWindowInBackground(WindowPtr whichWindow)
- {
- RgnHandle WindowRgn;
- long newLoc;
- Rect limitRect;
- Point mousePt;
- Point WindowTopLeft;
- GrafPtr wPort;
-
- WindowTopLeft = topLeft(whichWindow->portRect);
- LocalToGlobal(&WindowTopLeft);
-
- wPort = (GrafPtr)NewPtrClear(sizeof(GrafPort));
- OpenPort(wPort);
- CopyRgn(GetGrayRgn(),wPort->visRgn);
- SetPort(wPort);
-
- mousePt = gTheEvent.where;
- GlobalToLocal(&mousePt);
-
- limitRect = (**GetGrayRgn()).rgnBBox;
-
- WindowRgn = NewRgn();
- CopyRgn(((WindowPeek)whichWindow)->strucRgn, WindowRgn);
-
- newLoc = DragGrayRgn(WindowRgn,
- mousePt,
- &limitRect,
- &limitRect,
- noConstraint,
- nil);
-
- if (newLoc != 0x80008000)
- {
- short hDelta;
- short vDelta;
-
- hDelta = LoWord(newLoc);
- vDelta = HiWord(newLoc);
-
- if (hDelta || vDelta)
- MoveWindow(whichWindow,
- hDelta + WindowTopLeft.h,
- vDelta + WindowTopLeft.v,
- false);
-
- }
- DisposeRgn(WindowRgn);
- ClosePort(wPort);
- DisposPtr(wPort);
-
- }
-
- - --
- carl
- haynes@mace.cc.purdue.edu
- AOL: CWH3
-
- +++++++++++++++++++++++++++
-
- From: d88-jwa@hemul.nada.kth.se (Jon W{tte)
- Date: 30 Mar 92 08:39:02 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- .se> ollef@sics.se (Olle Furberg) writes:
-
- I'm trying to implement movable modal dialog box.
-
- How could I move an inactive window without getting it activated through
- SelectWindow?
-
- Tell me, how does your movable modal get inactive ?
-
- Or do you want to move windows behind the modal ? I don't think
- that's supported; only moving the modal is.
-
- - --
- h+@nada.kth.se; Jon W{tte, the Diplomat - NOT!
-
- +++++++++++++++++++++++++++
-
- From: Keith_Rollin@taligent.com (Keith Rollin)
- Date: 30 Mar 92 23:01:44 GMT
- Organization: Taligent
-
- In article <42942@mentor.cc.purdue.edu>, haynes@mace.cc.purdue.edu (Carl W. Haynes III) writes:
- >
- > In article <1992Mar29.174435.17655@sics.se> ollef@sics.se (Olle Furberg) writes:
- > >
- > >I'm trying to implement movable modal dialog box.
- > >
- > >How could I move an inactive window without getting it activated through
- > >SelectWindow?
- > >
- >
- > You need to write your own DragWindow routine. Here's what I use:
- > I'm sure I stole this from somewhere, but don't remember where off hand.
- > As always, add error checking where needed.
- >
- >
- > void DragWindowInBackground(WindowPtr whichWindow)
- > {
- [ code deleted ]
- > }
-
- Off the top of my head, it looks like the place you stole it from
- was TCL, but I could be wrong.
-
- Another shorter-hackier-but-way-cool way to drag windows around
- without bringing them to front is to set the bit that corresponds
- to the Command key in the keymap in low-memory just before calling
- DragWindow. I make no guarantees as to how long this trick will
- work, so you'll have to decide for yourself if you want to try it.
- For what it's worth, I think that early versions of HyperCard
- did this (I don't know if it still does).
-
- ---------------------------
-
- From: flemmon@Auspex.COM (Frank Lemmon)
- Subject: Mac development environment questions...
- Date: 30 Mar 92 18:34:35 GMT
- Organization: Auspex Systems, Santa Clara
-
- I'm interested in writing a Mac application and would like
- recommendations on how to get started. Questions I have:
-
- 1. I've heard that "Think C" is one of the best programming environments
- to deal with. Is this correct, and is this the standard, retail
- Think C from Symantec or some special version?
-
- 2. How does one find out about system resources, names, header files,
- etc. that are required for programming an application?
-
- 3. I would like to obtain copies of stuffit, unstuffit, and binhex that
- are frequently referred to by the experienced. Where can I get
- these?
-
- Thanks in advance,
-
- Frank Lemmon
- "Fledgling Mac Programmer"
- flemmon@auspex.com
-
- +++++++++++++++++++++++++++
-
- From: flemmon@Auspex.COM (Frank Lemmon)
- Date: 31 Mar 92 19:59:48 GMT
- Organization: Auspex Systems, Santa Clara
-
-
- Thanks to those of you who responded via e-mail. I have my feet in
- the starting blocks now ;-)
-
- Frank Lemmon
- flemmon@auspex.com
-
- ---------------------------
-
- Subject: Video page flipping?
- From: pdbourke@ccu1.aukuni.ac.nz (Paul David Bourke)
- Date: Tue, 31 Mar 1992 00:41:58 GMT
- Organization: University of Auckland, New Zealand.
-
- Does anyone have any code (preferably C but Pascal is OK) that they would
- mind sharing that reconfigures the Mac II video cards to consist of two
- pages (at half the depth each) instead of a singe page. I need to be able to
- flip between two images, once per refeash.
- Please email me as I rarely find time to read this group
-
- pdbourke@ccu1.aukuni.ac.nz
-
-
- ---------------------------
-
- From: wusyk@warsteiner.bnr.ca (Walter Usyk)
- Subject: Shareware C and C++ compilors for the Mac
- Date: 31 Mar 92 03:54:21 GMT
- Organization: Bell Northern Research Montreal, Canada.
-
- Does anybody know of a ftp site which has a C and/or C++
- compiler available as shareware???
-
-
- **************************************************************
- * Walter Usyk: Bell-Northern Research, Montreal Canada *
- * *
- * Telephone : (514) 765-8259 *
- * *
- * Internet : bnrmtl!wusyk@Larry.McRCIM.McGill.EDU *
- * *
- **************************************************************
-
-
- - --
- **************************************************************
- * Walter Usyk: Bell-Northern Research, Montreal Canada *
- * *
- * Telephone : (514) 765-8259 *
-
- +++++++++++++++++++++++++++
-
- From: e-sink@uiuc.edu (Eric W. Sink)
- Organization: University of Illinois at Urbana-Champaign
- Date: Tue, 31 Mar 1992 13:48:35 GMT
-
- In <1992Mar31.035421.21871@bnrmtl.bnr.ca> wusyk@warsteiner.bnr.ca (Walter Usyk) writes:
-
- >Does anybody know of a ftp site which has a C and/or C++
- >compiler available as shareware???
-
- Do you want the bad news first, or the other bad news first ?
-
- 1. Mail to your site bounces from my machine
- 2. There is no reliable shareware C compiler for the Mac.
- There is Sesame C, but it lacks a large part of the C language.
- There is Harvest C, which I develop, but it's very buggy. I've
- been doing in-house testing of my next release, and judging from
- some of the bugs I've fixed, my last release was REALLY buggy. :-)
- Version 1.2 will go alpha very soon.
- 3. There is no shareware C++ compiler for the Mac, at all.
-
- Should this subject be addressed in some way in the FAQ list ?
-
- - --
- Eric W. Sink, Spatial Analysis and Systems Team
- USACERL, P.O. Box 9005, Champaign, IL 61826-9005
- 1-800-USA-CERL x449, e-sink@uiuc.edu
-
- +++++++++++++++++++++++++++
-
- From: cwalker@canopus.tmc.edu (carleton walker `93)
- Date: 31 Mar 92 17:35:38 GMT
- Organization: Bucknell University, Lewisburg, Pa.
-
- In article <1992Mar31.035421.21871@bnrmtl.bnr.ca> wusyk@warsteiner.bnr.ca (Walter Usyk) writes:
- >Does anybody know of a ftp site which has a C and/or C++
- >compiler available as shareware???
-
- You can pick up gcc at summex (36.44.0.6). I haven't tried it
- out yet. Does anyone know how well it works?
-
- Carl Walker
- - --
- Carl Walker "Hectic days ahead of us,
- Bucknell University Rotten ones behind,
- Lewisburg, PA Keeping plastics in our pockets,
- Children never mind." - K, S, & W
-
- +++++++++++++++++++++++++++
-
- From: mlanett@void.ncsa.uiuc.edu (Mark Lanett)
- Date: 31 Mar 92 18:32:55 GMT
- Organization: University of Illinois at Urbana
-
- cwalker@canopus.tmc.edu (carleton walker `93) writes:
-
- > You can pick up gcc at summex (36.44.0.6). I haven't tried it
- >out yet. Does anyone know how well it works?
-
- It's gcc 1.37 (2.0 by the end of summer, maybe). It requires the MPW 3.1
- (NOT 3.2) headers and libraries (which you can get for free from Apple) and
- the MPW Shell and Assembler (which are not free). It also requires more
- time/cpu/memory than MPW C. It doesn't generate SADE symbols.
- - --
- Mark Lanett, Software Tools Group, NCSA mlanett@uiuc.edu or NCSA.STG
- "People wander in and out of virtual rooms in virtual settings with virtual
- characters and virtual money and virtual armor and virtual weapons, which is
- virtually a good way to spend time, but not quite." -- Usenet Oracle
-
- +++++++++++++++++++++++++++
-
- From: neeri@iis.ethz.ch (Matthias Ulrich Neeracher)
- Date: 31 Mar 92 21:01:45 GMT
- Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
-
- cwalker@canopus.tmc.edu (carleton walker `93) writes:
-
- >In article <1992Mar31.035421.21871@bnrmtl.bnr.ca> wusyk@warsteiner.bnr.ca (Walter Usyk) writes:
- >>Does anybody know of a ftp site which has a C and/or C++
- >>compiler available as shareware???
-
- > You can pick up gcc at summex (36.44.0.6). I haven't tried it
- >out yet. Does anyone know how well it works?
-
- It works, but it needs the MPW shell and MPW Assembler, neither of which
- is shareware or PD.
-
- Matthias
-
- - -----
- Matthias Neeracher neeri@iis.ethz.ch
- "I came to the conclusion that sex is a sublimation
- of the work instinct" -- David Lodge, _Small World_
-
- ---------------------------
-
- From: mike@zorch.SF-Bay.ORG (Mike Smithwick)
- Subject: scrollbar thumb question
- Organization: SF-Bay Public-Access Unix
- Date: Tue, 31 Mar 1992 07:45:23 GMT
-
- []
- I want to be able to dynamically update some information when the user
- moves the thumb of a scroll bar. Trouble is it appears that the
- control value doesn't seem to be updated until the thumb is released.
-
- So how can I get the intermediate value from the scrollbar?
-
-
- - --
- "There is no problem too big that can't be solved with high explosives"-Rush
-
- Mike Smithwick - ames!zorch!mike
-
-
- +++++++++++++++++++++++++++
-
- From: time@ice.com (Tim Endres)
- Date: 31 Mar 92 13:44:18 GMT
- Organization: ICE Engineering, Inc.
-
-
- In article <1992Mar31.074523.26603@zorch.SF-Bay.ORG> (comp.sys.mac.programmer), mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
- > I want to be able to dynamically update some information when the user
- > moves the thumb of a scroll bar. Trouble is it appears that the
- > control value doesn't seem to be updated until the thumb is released.
- >
- > So how can I get the intermediate value from the scrollbar?
-
- I believe you would need to write your own CDEF for this...
-
-
- tim endres - time@ice.com -or- uupsi!tbomb!time
- ICE Engineering, Inc. - Phone (313) 449 8288 - FAX (313) 449-9208
- 8840 Main Street, Whitmore Lake, MI 48189
- USENET - a slow moving self parody... ph
-
- ---------------------------
-
- Subject: Summary: Color drawing question
- From: jmatthews@desire.wright.edu
- Date: 30 Mar 92 23:18:40 EST
- Organization: Wright State University
-
- Recently I asked:
-
- >I'm iterating a function and plotting the resulting co-ordinate pairs
- >to make a picture....I'd like to alter the foreground color by
- >examining the pixel I'm about to draw and picking a darker shade if
- >I've been there before....Is a palette the right choice?
-
- It turns out a palette of tolerant colors is the right choice, but
- there's no need to examine pixels or mess with CTab/Palette indexes.
- The QuickDraw arithmetic drawing mode subPin (IM5, p59) does the right
- thing. Just call OpColor with the rbg value for the darkest shade
- desired, and call RGBForeColor with the rbg value by which to
- decrement the target pixels. Presto: shades!
-
- Thanks to all who responded.
-
- o----------------------------------------------------------------------------o
- | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
- | "I'm a commensal .sig virus, indistinguishable from an ordinary organelle."|
- o----------------------------------------------------------------------------o
-
- ---------------------------
-
- From: jgrape@coos.dartmouth.edu (Johan A. Grape)
- Subject: Strange undocumented think Pascal error message
- Date: 31 Mar 92 14:45:02 GMT
- Organization: Dartmouth College, Hanover, NH
-
- The other day, I was coding away on my Mac, compiled the code and ran
- it when Think Pascal gave me this wonderful error message:
-
- "The system Zone is damaged. Proceed with caution"
-
- I was running in the Think Pascal environment.
-
- The great thing is that any old program (not only the one I was writing,
- but older projects as well) give me this message whenever execution
- is terminated (either by clicking on the bug spray or by the program
- terminating by it self). It does not seem to interfere with the
- execution at all, just pop up when the program terminates. Pain in
- the ...
-
- Anybody seen this before? It is completely undocumented. The only thing I
- did that was new prior to running think pascal was that I ran Retrospect
- to back up my drives.
-
- Oh yes - I am going to reinstall Think Pascal to see if it goes away, but
- I am posting this to see if anyone else has had similar problems. One
- has to wonder how many undocumented error messages are hidden in the
- think pascal environment. My version is 4.0.
-
- Thanks in advance for any advice.
-
- Johan
-
- - -------------------------------------------------------------------------
-
- "God is alive and well and working on a less ambitious project."
- Supreme.being@dartmouth.edu
- jgrape@coos.dartmouth.edu
- _________________________________________________________________________
-
- +++++++++++++++++++++++++++
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Date: 31 Mar 92 15:59:14 GMT
- Organization: Kalamazoo College
-
- jgrape@coos.dartmouth.edu (Johan A. Grape) writes:
- >
- >The other day, I was coding away on my Mac, compiled the code and ran
- >it when Think Pascal gave me this wonderful error message:
- >
- > "The system Zone is damaged. Proceed with caution"
-
- Are you running GateKeeper?
-
- Versions of GateKeeper before the latest (1.2.5) corrupt the System heap
- in a very minor way, so minor that apparently only Think Pascal and
- Swatch notice.
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
-
- +++++++++++++++++++++++++++
-
- From: Carl.Constantine@BCSystems.GOV.BC.CA
- Date: 31 Mar 92 20:17:44 GMT
- Organization: BC Systems Corporation
-
- In article <1992Mar31.144502.22500@dartvax.dartmouth.edu>, jgrape@coos.dartmouth.edu (Johan A. Grape) writes:
- > The other day, I was coding away on my Mac, compiled the code and ran
- > it when Think Pascal gave me this wonderful error message:
- >
- > "The system Zone is damaged. Proceed with caution"
- >
- > I was running in the Think Pascal environment.
- >
- > The great thing is that any old program (not only the one I was writing,
- > but older projects as well) give me this message whenever execution
- > is terminated (either by clicking on the bug spray or by the program
- > terminating by it self). It does not seem to interfere with the
- > execution at all, just pop up when the program terminates. Pain in
- > the ...
- >
- > Anybody seen this before? It is completely undocumented. The only thing I
- > did that was new prior to running think pascal was that I ran Retrospect
- > to back up my drives.
- >
- > Oh yes - I am going to reinstall Think Pascal to see if it goes away, but
- > I am posting this to see if anyone else has had similar problems. One
- > has to wonder how many undocumented error messages are hidden in the
- > think pascal environment. My version is 4.0.
- >
- > Thanks in advance for any advice.
- >
- > Johan
- >
-
- First of all, you should upgrade to THINK Pascal 4.0.1. You can get the fix
- via anonymous FTP from Sumex-aim [36.44.0.6]. You probably have a dangling
- pointer. I have had this happen to me before to and what happens is that your
- project file becomes corrupted and you will get this msg. every time you run
- that program. You will need to delete the project and rebuild it (I hope it's
- not too large).
-
- Other projects that you run, may also become corrupted if you ran them without
- rebooting your machine first. I've had this happen to me befoer too. also if
- you've quit an application without cleaning up properly (ie: the pointer or
- handle problem again) this will happen also.
-
- I exited a graphing program I was writting this way because it hung, and I got
- the same stuff you did.
-
- - --
- Carl.Constantine@BCSystems.gov.bc.ca
- Victoria, British Columbia, Canada
-
- ---------------------------
-
- End of C.S.M.P. Digest
- **********************
-